liwe.sound = {
	_refs: {}
};

liwe.sound.load = function ( id, baseurl, files )
{
	if ( liwe.sound._refs [ id ] ) return;

	var i, audio = document.createElement ( 'audio' );

	for ( i = 0; i < files.length; i++ )
	{
		var source = document.createElement ( 'source' );
		source.src = baseurl + files [ i ];
		audio.appendChild ( source );
	}

	liwe.sound._refs [ id ] = audio;
};

liwe.sound.play = function ( id )
{
	var audio = liwe.sound._refs [ id ];
	if ( ! audio ) return;

	try
	{
		audio.play ();
	} catch ( e ) {
	}
};

liwe.sound.pause = function ( id )
{
	var audio = liwe.sound._refs [ id ];
	if ( ! audio ) return;

	try
	{
		audio.pause ();
	} catch ( e ) {
	}
};

liwe.sound.rewind = function ( id )
{
	var audio = liwe.sound._refs [ id ];
	if ( ! audio ) return;

	try
	{
		audio.currentTime = 0;
	} catch ( e ) {
	}
};

liwe.sound.paused = function ( id )
{
	var audio = liwe.sound._refs [ id ];
	if ( ! audio ) return;

	try
	{
		return audio.paused;
	} catch ( e ) {
		return null;
	}
};
